﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="label_createurl.aspx.cs" Inherits="YXShop.Web.admin.templates.label.label_createurl" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>无标题页</title>
    <link href="../../style/admin.css" rel="stylesheet" type="text/css" />
 <script language="JavaScript" type="text/javascript" src="../../../scripts/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="../../scripts/public.js"></script>
<script language="javascript" type="text/javascript">
function SetParameter()
{
    var Parameter;
    var o=document.getElementsByName("rblParameter");
    for (var i=0;i<o.length ;i++ )
    {
         if( o[i].checked==true )
         {
              Parameter=o[i].value;
         }
     }
     if(Parameter=="0")
     {
         document.getElementById("tdParameter").style.display="none";
         document.getElementById("txtParameter").value="URLParameter";
     }
     else
     {
         document.getElementById("tdParameter").style.display="";
         document.getElementById("txtParameter").value="";
     }
}
function ReturnValue()
{
    var FileName= document.getElementById("txtFileName").value;
    if(FileName=="")
    {
         document.getElementById("sp").innerHTML=" * 文件名不能为空！";
         return false;
    }
    var FilePath= document.getElementById("txtFilePath").value;
    var FileParameter= document.getElementById("txtParameter").value;
    
    
    var Target;//打开方式
    var o=document.getElementsByName("rbOpenMether");
    for (var i=0;i<o.length ;i++ )
    {
     if( o[i].checked==true )
     {
      Target=o[i].value;
     }
     }
    //自定义内容
    var mystyle = document.getElementById("txtLabelContent").value;
	var cnm ="[YX:unLoop,YX:LableType=CreateURL,YX:FileName="+FileName+",YX:URLParameter="+FileParameter+",YX:FilePath="+FilePath+",YX:Target="+Target+"]"+mystyle+"[/YX:unLoop]";
	 
    parent.getValue(cnm);
	 CloseDiv();

}

function getValue(value)
{
    if(value!="") 
    {
        var oEditor = FCKeditorAPI.GetInstance("fckLabelContent");
        if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG)
        {
           oEditor.InsertHtml(value);
           
        }
        
        else
        {
        return false;
        }
    }
}
function CloseDiv()
{
    parent.document.getElementById("LabelDivid").style.display="none";
}

function SelChannel(value)
{
    if(value!="0")
    {
        document.getElementById("txtFileName").value="index";
        document.getElementById("txtFilePath").value="article/";
        document.getElementById("txtParameter").value="q_ChannelId="+value;
    }
    else
    {
        document.getElementById("txtFileName").value="";
        document.getElementById("txtFilePath").value="";
        document.getElementById("txtParameter").value="";
    }
}
    function getValue(value)
    {
        var textObj=document.getElementById("txtLabelContent");
        var textFeildValue=value;
        if(value!="") 
        {
            if(document.all)
            {     
                if(textObj.createTextRange && textObj.caretPos)
                {   
                    var caretPos=textObj.caretPos;   
                    caretPos.text=caretPos.text.charAt(caretPos.text.length-1)==''?textFeildValue+'':textFeildValue;   
                }
                else
                {   
                    textObj.value=textFeildValue;   
                }   
            }
            else
            {   
                if(textObj.setSelectionRange)
                {   
                    var rangeStart =textObj.selectionStart;   
                    var rangeEnd=textObj.selectionEnd;   
                    var tempStr1=textObj.value.substring(0,rangeStart);   
                    var tempStr2 =textObj.value.substring(rangeEnd);   
                    textObj.value=tempStr1+textFeildValue+tempStr2;   
                }
                else
                {   
                    alert("This version of Mozilla based browser does not support setSelectionRange");   
                }   
            }
        }
    }
    function setCaret(textObj)
    {   
        if(textObj.createTextRange)
        {   
            textObj.caretPos=document.selection.createRange().duplicate();   
        }   
    } 
    function setType(strId)
    {
        if(strId=="2")
        {
            document.getElementById("Channel").style.display="none";
            document.getElementById("ProductClass").style.display="none";
            document.getElementById("SystemNav").style.display="none";
        }
        else if(strId=="1")
        {
            document.getElementById("Channel").style.display="none";
            document.getElementById("ProductClass").style.display="";
            document.getElementById("SystemNav").style.display="none";
        }
        else if(strId=="0")
        {
            document.getElementById("Channel").style.display="";
            document.getElementById("ProductClass").style.display="none";
             document.getElementById("SystemNav").style.display="none";
        }
        else if(strId=="3")
        {
            document.getElementById("Channel").style.display="none";
            document.getElementById("ProductClass").style.display="none";
            document.getElementById("SystemNav").style.display="";
        }
        document.getElementById("txtFileName").value="";
	    document.getElementById("txtFilePath").value="";
	    document.getElementById("txtParameter").value="";
	    document.getElementById("txtLabelContent").value="";
    }
    function SystemType(va)
    {
        if(va!="")
        {
            var str=va.value.split('|');
            if(str.length>2)
            {
                document.getElementById("txtFileName").value=str[0];
	            document.getElementById("txtFilePath").value=str[1];
	            document.getElementById("txtParameter").value=str[3];
	            document.getElementById("txtLabelContent").value=str[2];
	        }
	    }
        
    }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="table_label_parameter" cellpadding="1" cellspacing="1" style="width: 99%; margin-top:5px">
            <tr>
                <td>设置类型：</td>
                <td>
                    <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
                        <asp:ListItem Value="0" Text="资讯频道" Selected="True" onclick="setType('0')" />
                        <asp:ListItem Value="1" Text="商品分类" onclick="setType('1')" />
                        <asp:ListItem Value="3" Text="系统类型" onclick="setType('3')"/>
                        <asp:ListItem Value="2" Text="普通类型" onclick="setType('2')" />
                        
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr id="SystemNav" style="display:none">
                <td>系统类型：</td>
                <td>
                    <select id="selSystemType" onchange="SystemType(this)">
                        <option value="">-请选择-</option>
                        <option value="default||首页|">首页</option>
                        <option value="productclass|product/|商品列表|">商品列表</option>
                        <option value="special|product/|特价商品|">特价商品</option>
                        <option value="brandlist|brand/|品牌专卖|">品牌专卖</option>
                        <option value="productordercardlist|product/|点卡|">点卡</option>
                        <option value="product_auction_list|product/|拍卖|">拍卖</option>
                        <option value="product_groupbuy_list|product/|团购|">团购</option>
                        <option value="shoplist|product/|商铺|">商铺</option>
                        <option value="shoppingcart|product/|购物车|">购物车</option>
                        <option value="leaveword|other/|客户留言|">客户留言</option>
                        <option value="outStock|other/|缺货登记|">缺货登记</option>
                        <option value="default|comment/|商品点评|">商品点评</option>
                        <option value="member_index|membercenter/|我的账户|">我的账户</option>
                    </select>
                </td>
            </tr>
            <tr id="Channel">
                <td>资讯频道：</td>
                <td>
                    <asp:DropDownList ID="ddlChannel" runat="server" onchange="SelChannel(this.value)"></asp:DropDownList>
                    <span style="color:Red;">注：此项只针对资讯频道做链接</span>
                </td>
            </tr>
            <tr id="ProductClass" style="display:none">
                <td>商品分类：</td>
                <td>
                    <asp:TextBox ID="txtProductClass" runat="server"></asp:TextBox>
                    <asp:HiddenField runat="server" ID="hfcid" />
                    <span style="color:Red;">注：此项只针对商品分类做链接</span>
                </td>
            </tr>
            <tr>
                <td>文件名称：</td>
                <td><asp:TextBox ID="txtFileName" runat="server"></asp:TextBox><span id="sp" style="color:Red;"></span></td>
            </tr>
            <tr>
                <td>文件路径：</td>
                <td><asp:TextBox ID="txtFilePath" runat="server"></asp:TextBox><span style="color:Red">注：以“/”结束，如（product/），默认为空。</span></td>
            </tr>
            <tr>
                <td>参数设置：</td>
                <td>
                    <asp:RadioButtonList ID="rblParameter" RepeatDirection="Horizontal" onclick="javascript:SetParameter()" runat="server">
                        <asp:ListItem Text="获取页面URL参数" Value="0"></asp:ListItem>
                        <asp:ListItem Text="自定义参数" Value="1" Selected="True"></asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr id="tdParameter">
                <td>传递参数：</td>
                <td><asp:TextBox ID="txtParameter" runat="server"></asp:TextBox><span style="color:Red;">注：多个参数用分号(；)隔开，如（parameter1=参数1;parameter2=参数2...）</span></td>
            </tr>
             <tr>
                <td>打开方式：</td>
                <td>
                    <asp:RadioButtonList ID="rbOpenMether" runat="server" RepeatDirection="Horizontal"> 
                        <asp:ListItem Value="_blank" Selected="True">_blank</asp:ListItem>
                        <asp:ListItem Value="_top">_top</asp:ListItem>
                        <asp:ListItem Value="_parent">_parent</asp:ListItem>
                        <asp:ListItem Value="_self">_self</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                
                <td colspan="2">
                <span style="color:Red">注：如下面文本框没有文字标签只解晰为URL，如有文字解晰为带链接的URL。（如：有文字解晰为'&lt;a href="URL"&gt;文字&lt;/a&gt;'；没有文字解晰为URL。 ）</span>
                    <asp:TextBox runat="server" ID="txtLabelContent" height="100" onselect="setCaret(this);"  onclick="setCaret(this);"  onkeyup="setCaret(this);" Width="600" TextMode="MultiLine"></asp:TextBox>
                     </td>
            </tr>
            
            <tr>
                <td colspan="4" align="center" style="text-align:center">
                   <input id="bt_Exc" type="button" value="提交" onclick="ReturnValue()" />
                    &nbsp;<input class="form" type="button" value=" 关 闭 "  onclick="javascript:CloseDiv();" /></td>
            </tr>
            </table>
    </div>
    </form>
</body>
</html>